
# 发送激活邮箱的邮件
from django.core.mail import send_mail
from django.conf import settings
from users.utlis import generic_active_url
from celery_tasks.main import app

@app.task(name='send_active_email')
def send_active_email(email,user_id):
    #subject message  from_email recipient_list
    #subject主题
    subject = '抽到镰刀'
    #message 内容
    message = '抽到镰刀吧'
    #from_email  发件人
    from_email = settings.EMAIL_FROM
    #recipient_list 接收人列表

    recipien_list = [email]

    verify_url=generic_active_url(user_id,email)
    #可以设置一下html的样式等信息
    html_message = '<p>尊敬的用户您好！</p>' \
               '<p>感谢您使用美多商城。</p>' \
               '<p>您的邮箱为：%s 。请点击此链接激活您的邮箱：</p>' \
               '<p><a href="%s">%s<a></p>' % (email, verify_url, verify_url)

    send_mail(subject=subject,
              message=message,
              from_email=from_email,
              recipient_list=recipien_list,
              html_message=html_message
              )